package com.zb.sannuo.thereport.service.impl;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.zb.sannuo.common.domain.search.Abnormal;
import com.zb.sannuo.common.domain.vo.ReportVo;
import com.zb.sannuo.thereport.mapper.AbnormalMapper;
import com.zb.sannuo.thereport.service.AbnormalService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AbnormalServiceImpl implements AbnormalService {

    @Resource
    private AbnormalMapper abnormalMapper;

    @Override
    public List<Abnormal> queryAbnormal(String searchParams) {
        ObjectMapper mapper = new ObjectMapper();
        ReportVo reportVo = null;
        if (searchParams != null && !"".equals(searchParams)){
            try {
                reportVo = mapper.readValue(searchParams, ReportVo.class);
            } catch (JsonProcessingException e) {
                e.printStackTrace();
            }
        }

        List<Abnormal> list = abnormalMapper.queryAbnormal(reportVo);
        return list;
    }
}
